package com.example.home.adapter

import com.chad.library.adapter.base.BaseProviderMultiAdapter
import com.example.entity.BaseEntity
import com.example.home.R
import com.example.home.adapter.provider.CategoryCardProvider
import com.example.home.adapter.provider.ContentBannerProvider
import com.example.home.adapter.provider.SubjectCardProvider
import com.example.home.adapter.provider.ThemeCardProvider
import com.example.home.adapter.provider.TitleProvider
import com.example.home.adapter.provider.TopBannerProvider
import com.example.home.adapter.provider.VideoCardProvider
import com.example.home.entity.discover.CategoryCardEntity
import com.example.home.entity.discover.SubjectCardEntity
import com.example.home.entity.viewdata.BriefCardViewData
import com.example.home.entity.viewdata.ContentBannerViewData
import com.example.home.entity.viewdata.FollowCardViewData
import com.example.home.entity.viewdata.SingleTitleViewData
import com.example.home.entity.viewdata.TitleCardViewData
import com.example.home.entity.viewdata.TopBannerViewData
import com.example.home.entity.viewdata.VideoCardViewData

class DiscoverListAdapter : BaseProviderMultiAdapter<BaseEntity>() {


    init {
        addItemProvider(TopBannerProvider())
        addItemProvider(CategoryCardProvider())
        addItemProvider(SubjectCardProvider())
        addItemProvider(TitleProvider(DiscoverItemType.TITLE_VIEW,R.layout.item_home_title))
        addItemProvider(ContentBannerProvider())
        addItemProvider(VideoCardProvider(DiscoverItemType.VIDEO_CARD_VIEW, R.layout.item_video_card_view))
        addItemProvider(ThemeCardProvider())

    }

    override fun getItemType(data: List<BaseEntity>, position: Int): Int {
        var entity =data[position]

        return when(entity){
            is TopBannerViewData -> DiscoverItemType.TOP_BANNER_VIEW
            is CategoryCardEntity -> DiscoverItemType.CATEGORY_CARD_VIEW
            is SubjectCardEntity -> DiscoverItemType.SUBJECT_CARD_VIEW
            is TitleCardViewData -> DiscoverItemType.TITLE_VIEW
            is ContentBannerViewData -> DiscoverItemType.CONTENT_BANNER_VIEW
            is VideoCardViewData -> DiscoverItemType.VIDEO_CARD_VIEW
            is BriefCardViewData -> DiscoverItemType.THEME_CARD_VIEW
            else -> NominateItemType.DEFAULT_VIEW
        }
    }
}